/**
 * 
 */
package kr.pe.johnkim.dayve.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author johnkim
 *
 */
public class DayveItemDatabaseHelper extends SQLiteOpenHelper {
	
	private static final String TAG = DayveItemDatabaseHelper.class.getSimpleName();

	private static final String DATABASE_NAME = "database_dayve_item.db";
	private static final int DATABASE_VERSION = 10;
	
	public DayveItemDatabaseHelper(Context context) {
		super(context,  DATABASE_NAME, null, DATABASE_VERSION);	
		Log.e(TAG, "DayveItemDatabaseHelper");
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		// Item 테이블을 생성 한다.
		db.execSQL(
				" CREATE TABLE if not exists dayve_item" + 
						" (" +
						"	  _id				   						   INTEGER PRIMARY KEY AUTOINCREMENT" + 
						"	, id_myhistory_items   						   TEXT" +
						"   , name				   						   TEXT" +
						"   , comment 			   						   TEXT" +
						"   , amount			   						   TEXT" + 
						"   , open_item_yn		   						   TEXT" +
						"   , favorite_yn		   						   TEXT" + 
						"	, activate_yn		   						   TEXT" +
						"	, modify_date		   						   TEXT" +
						"   , register_date		   						   TEXT" +
						"   , myhistory_members_id 	    				   TEXT" + 
						"   , myhistory_categories_id_myhistory_categories TEXT" + 
						");"
				);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		// Item 테이블을 삭제 한다.
		db.execSQL("DROP TABLE if exists dayve_item");

		// 테이블을 새로 생성 한다.
		onCreate(db);
	}

}
